package com.example.mapper;

import com.example.model.Employee;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface EmployeeMapper {

    @Select("SELECT * FROM employees")
    List<Employee> findAll();

    @Select("SELECT * FROM employees WHERE id = #{id}")
    Employee findById(Long id);

    @Insert("INSERT INTO employees (name, email, department, hire_date, salary) " +
            "VALUES (#{name}, #{email}, #{department}, #{hireDate}, #{salary})")
    @Options(useGeneratedKeys = true, keyProperty = "id")
    int insert(Employee employee);

    @Update("UPDATE employees SET name = #{name}, email = #{email}, " +
            "department = #{department}, hire_date = #{hireDate}, salary = #{salary} " +
            "WHERE id = #{id}")
    int update(Employee employee);

    @Delete("DELETE FROM employees WHERE id = #{id}")
    int delete(Long id);
}